#pragma once
#include <iostream>
#include <string>
#include <sstream>
#include <stdexcept>
#include <map>
#include "SDL.h"
#include "SDL_image.h"
#include "SDLRenderer.h"
#include "SDLAudio.h"
#include "SDL_ttf.h"
#include "XMLReader.h"

class SDLResources
{
#pragma region SINGLETON
public:
	static SDLResources* GetInstance()
	{
		if(instance == nullptr)
		{
			instance = new SDLResources();
		}
		return instance;
	}
	static void Kill()
	{
		delete instance;
		instance = nullptr;
	}
private:
	static SDLResources* instance;

	SDLResources();
	SDLResources(const SDLResources& r);
	~SDLResources();

	SDLResources& operator=(const SDLResources& r);
#pragma endregion

public:
	SDL_Texture* GetTexture(std::string fileName);
	Mix_Music* GetMusic(std::string fileName);
	Mix_Chunk* GetSound(std::string fileName);
	TTF_Font* GetFont(std::string fileName, int fontSize);

private:
	std::map<std::string, SDL_Texture*> loadedTextures;
	std::map<std::string, Mix_Music*> loadedMusics;
	std::map<std::string, Mix_Chunk*> loadedSounds;
	std::map<std::string, TTF_Font*> loadedFonts;

	SDL_Texture* LoadImage(std::string file, SDL_Renderer* renderer);
	Mix_Music* LoadMusic(std::string file);
	Mix_Chunk* LoadSound(std::string file);
	TTF_Font* LoadFont(std::string file, int fontSize);
};